#include "SMPPDeliverSM.hpp"

using namespace smpp::pdu;

DeliverSM::DeliverSM(const Header &nHeader,
const CoctetString &nServiceType,
const quint8 nSourceAddrTON,
const quint8 nSourceAddrNPI,
const CoctetString &nSourceAddr,
const quint8 nDestAddrTON,
const quint8 nDestAddrNPI,
const CoctetString &nDestAddr,
const quint8 nEsmClass,
const quint8 nProtocolId,
const quint8 nPriorityFlag,
const CoctetString &nScheduleDeliveryTime,
const CoctetString &nValidityPeriod,
const quint8 nRegisteredDelivery,
const quint8 nReplaceIfPresentFlag,
const quint8 nDataCoding,
const quint8 nSMDefaultMsgId,
const quint8 nSMLength,
const octetString &nShortMessage,
const MessageDeliveryRequestTLVs &nMessageDeliveryRequestTLVs):
Header(nHeader),
_ServiceType(nServiceType),
_SourceAddrTON(nSourceAddrTON),
_SourceAddrNPI(nSourceAddrNPI),
_SourceAddr(nSourceAddr),
_DestAddrTON(nDestAddrTON),
_DestAddrNPI(nDestAddrNPI),
_DestAddr(nDestAddr),
_EsmClass(nEsmClass),
_ProtocolId(nProtocolId),
_PriorityFlag(nPriorityFlag),
_ScheduleDeliveryTime(nScheduleDeliveryTime),
_ValidityPeriod(nValidityPeriod),
_RegisteredDelivery(nRegisteredDelivery),
_ReplaceIfPresentFlag(nReplaceIfPresentFlag),
_DataCoding(nDataCoding),
_SMDefaultMsgId(nSMDefaultMsgId),
_SMLength(nSMLength),
_ShortMessage(nShortMessage),
MessageDeliveryRequestTLVs(nMessageDeliveryRequestTLVs){}

DeliverSM::DeliverSM(const DeliverSM &nDeliverSM):
Header(nDeliverSM),
_ServiceType(nDeliverSM.getServiceType()),
_SourceAddrTON(nDeliverSM.getSourceAddrTON()),
_SourceAddrNPI(nDeliverSM.getSourceAddrNPI()),
_SourceAddr(nDeliverSM.getSourceAddr()),
_DestAddrTON(nDeliverSM.getDestAddrTON()),
_DestAddrNPI(nDeliverSM.getDestAddrNPI()),
_DestAddr(nDeliverSM.getDestAddr()),
_EsmClass(nDeliverSM.getEsmClass()),
_ProtocolId(nDeliverSM.getProtocolId()),
_PriorityFlag(nDeliverSM.getPriorityFlag()),
_ScheduleDeliveryTime(nDeliverSM.getScheduleDeliveryTime()),
_ValidityPeriod(nDeliverSM.getValidityPeriod()),
_RegisteredDelivery(nDeliverSM.getRegisteredDelivery()),
_ReplaceIfPresentFlag(nDeliverSM.getReplaceIfPresentFlag()),
_DataCoding(nDeliverSM.getDataCoding()),
_SMDefaultMsgId(nDeliverSM.getSMDefaultMsgId()),
_SMLength(nDeliverSM.getSMLength()),
_ShortMessage(nDeliverSM.getShortMessage()),
MessageDeliveryRequestTLVs(nDeliverSM){}

void DeliverSM::setServiceType(const CoctetString& sServiceType){
	_ServiceType = sServiceType;
}

const CoctetString &DeliverSM::getServiceType() const{
	return _ServiceType;
}

void DeliverSM::setSourceAddrTON(const quint8 nSourceAddrTON){
	_SourceAddrTON = nSourceAddrTON;
}

const quint8 DeliverSM::getSourceAddrTON() const{
	return _SourceAddrTON;
}

void DeliverSM::setSourceAddrNPI(const quint8 nSourceAddrNPI){
	_SourceAddrNPI = nSourceAddrNPI;
}

const quint8 DeliverSM::getSourceAddrNPI() const{
	return _SourceAddrNPI;
}

void DeliverSM::setSourceAddr(const CoctetString &sSourceAddr){
	_SourceAddr = sSourceAddr;
}

const CoctetString &DeliverSM::getSourceAddr() const{
	return _SourceAddr;
}

void DeliverSM::setDestAddrTON(const quint8 nDestAddrTON){
	_DestAddrTON = nDestAddrTON;
}

const quint8 DeliverSM::getDestAddrTON() const{
	return _DestAddrTON;
}

void DeliverSM::setDestAddrNPI(const quint8 nDestAddrNPI){
	_DestAddrNPI = nDestAddrNPI;
}

const quint8 DeliverSM::getDestAddrNPI() const{
	return _DestAddrNPI;
}

void DeliverSM::setDestAddr(const CoctetString& sDestAddr){
	_DestAddr = sDestAddr;
}
const CoctetString &DeliverSM::getDestAddr() const{
	return _DestAddr;
}

void DeliverSM::setEsmClass(const quint8 nEsmClass){
	_EsmClass = nEsmClass;
}

const quint8 DeliverSM::getEsmClass() const{
	return _EsmClass;
}

void DeliverSM::setProtocolId(const quint8 nProtocolId){
	_ProtocolId = nProtocolId;
}

const quint8 DeliverSM::getProtocolId() const{
	return _ProtocolId;
}

void DeliverSM::setPriorityFlag(const quint8 nPriorityFlag){
	_PriorityFlag = nPriorityFlag;
}

const quint8 DeliverSM::getPriorityFlag() const{
	return _PriorityFlag;
}

void DeliverSM::setScheduleDeliveryTime(
	const CoctetString &sScheduleDeliveryTime){
		_ScheduleDeliveryTime = sScheduleDeliveryTime;
}

const CoctetString& DeliverSM::getScheduleDeliveryTime() const{
	return _ScheduleDeliveryTime;
}

void DeliverSM::setValidityPeriod(const CoctetString &sValidityPeriod){
	_ValidityPeriod = sValidityPeriod;
}

const CoctetString &DeliverSM::getValidityPeriod() const{
	return _ValidityPeriod;
}

void DeliverSM::setRegisteredDelivery(const quint8 nRegisteredDelivery){
	_RegisteredDelivery = nRegisteredDelivery;
}

const quint8 DeliverSM::getRegisteredDelivery() const{
	return _RegisteredDelivery;
}

void DeliverSM::setReplaceIfPresentFlag(
	const quint8 nReplaceIfPresentFlag){
		_ReplaceIfPresentFlag = nReplaceIfPresentFlag;
}

const quint8 DeliverSM::getReplaceIfPresentFlag() const{
	return _ReplaceIfPresentFlag;
}

void DeliverSM::setDataCoding(const quint8 nDataCoding){
	_DataCoding = nDataCoding;
}

const quint8 DeliverSM::getDataCoding() const{
	return _DataCoding;
}

void DeliverSM::setSMDefaultMsgId(const quint8 nSMDefaultMsgId){
	_SMDefaultMsgId = nSMDefaultMsgId;
}

const quint8 DeliverSM::getSMDefaultMsgId() const{
	return _SMDefaultMsgId;
}

void DeliverSM::setSMLength(const quint8 nSMLength){
	_SMLength = nSMLength;
}

const quint8 DeliverSM::getSMLength() const{
	return _SMLength;
}

void DeliverSM::setShortMessage(const octetString &aShortMessage){
	_ShortMessage = aShortMessage;		
}

const octetString &DeliverSM::getShortMessage() const{
	return _ShortMessage;
}

void DeliverSM::calcCommandLength(){
	_CommandLength = 28 + _ServiceType.size() + _SourceAddr.size() +
		_DestAddr.size() + _ScheduleDeliveryTime.size() +
		_ValidityPeriod.size() + _SMLength + 
		MessageDeliveryRequestTLVs::getLength();
}
